//
//  JHChangePasswordView.m
//  XMPPChat
//
//  Created by WONG on 16/5/30.
//  Copyright © 2016年 cheuhui. All rights reserved.
//

#import "JHChangePasswordVC.h"

@interface JHChangePasswordVC ()

@property (weak, nonatomic) IBOutlet UITextField *usernameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
@property (weak, nonatomic) IBOutlet UITextField *confirmField;

@end

@implementation JHChangePasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


// 确认
- (IBAction)affirmClick:(id)sender {
    NSLog(@"点击确认");
    NSString *username = _usernameField.text;
    NSString *password = _passwordField.text;
    NSString *confirm = _confirmField.text;
    
    NSString *message = nil;
    if (username.length <= 0) {
        message = @"用户名未填写";
    } else if (password.length <= 0) {
        message = @"密码未填写";
    } else if (confirm.length <= 0) {
        message = @"确认密码未填写";
    }
    
    if (message.length > 0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
        [alertView show];
    } else if (![password isEqualToString:confirm]) {
        message = @"密码与确认密码不一致";
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
        [alertView show];
    } else {
        
        [[CZXMPPManager shareInstance] changePasswordWith:username password:password];
    }
}

- (IBAction)cancelClick:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end